package com.zrwl.poscloud.core.restapi.mobile;

import com.zrwl.poscloud.commons.exception.ThrowableUtils;
import com.zrwl.poscloud.commons.utils.ResultUtil;
import com.zrwl.poscloud.commons.validator.group.GetList;
import com.zrwl.poscloud.core.annotion.AuthorityVerify.AuthorityVerify;
import com.zrwl.poscloud.xo.service.StudentScoreBathService;
import com.zrwl.poscloud.xo.service.StudentScoreSubjectDetailService;
import com.zrwl.poscloud.xo.service.StudentScoreTotalDetailService;
import com.zrwl.poscloud.xo.service.UserService;
import com.zrwl.poscloud.xo.vo.StudentScoreBathVO;
import com.zrwl.poscloud.xo.vo.StudentScoreSubjectDetailVO;
import com.zrwl.poscloud.xo.vo.StudentScoreTotalDetailVO;
import com.zrwl.poscloud.xo.vo.UserEmployeeRVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 成绩发布 controller api类
 *
 * @author 刘思童 AutoGenerate
 * @date 2023-03-10
 */
@RestController
@Api(value = "成绩相关接口", tags = {"成绩相关接口"})
@RequestMapping("/userStudentScore")
@Slf4j
public class StudentScoreRestApi {
    @Autowired
    private StudentScoreBathService studentScoreBathService;
    @Autowired
    private StudentScoreSubjectDetailService studentScoreSubjectDetailService;
    @Autowired
    private UserService userService;
    @AuthorityVerify
    @ApiOperation(value = "获取当前学生的总分", notes = "获取当前学生的总分", response = String.class)
    @PostMapping("/getStudentScoreList")
    public String getStudentScoreList(@Validated({GetList.class}) @RequestBody StudentScoreBathVO studentScoreBathVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取成绩发布列表: {}", studentScoreBathVO);
        UserEmployeeRVO userEmployeeRVO = userService.getMe().getUserEmployeeRVO();
        studentScoreBathVO.setStudentUid(userEmployeeRVO.getEmployeeUid());
        return ResultUtil.successWithData(studentScoreBathService.getStudentScoreList(studentScoreBathVO));
    }
    @AuthorityVerify
    @ApiOperation(value = "获取当前学生成绩明细列表", notes = "获取当前学生成绩明细列表", response = String.class)
    @PostMapping("/getStudentScoreInfoList")
    public String getStudentScoreInfoList(@Validated({GetList.class}) @RequestBody StudentScoreSubjectDetailVO studentScoreSubjectDetailVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取当前学生成绩明细列表: {}", studentScoreSubjectDetailVO);
        return ResultUtil.successWithData(studentScoreSubjectDetailService.getStudentScoreInfoList(studentScoreSubjectDetailVO,"subject_type"));
    }
}
